package com.ebocy.hammer.battle;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.session.IoSession;

import com.ebocy.hammer.core.log.EbocyLogManager;
import com.ebocy.hammer.core.log.LoggerConstants.CuteLoggerType;

public class LogFilter  extends IoFilterAdapter  {
	Logger originalRecord1 = EbocyLogManager.getLogger(CuteLoggerType.ORIGINAL1, Level.INFO);
//	Logger originalRecord2 = EbocyLogManager.getLogger(CuteLoggerType.ORIGINAL2, Level.INFO);
//	Logger originalRecord3 = EbocyLogManager.getLogger(CuteLoggerType.ORIGINAL3, Level.INFO);
	
	@Override
	public void messageReceived(NextFilter nextFilter, IoSession iosession,
			Object message) throws Exception {
//		String address = iosession.getRemoteAddress().toString();
//		int flag = Integer.parseInt(address.substring(address.indexOf("16.") + 3, address.indexOf(":")));
		IoBuffer in = (IoBuffer)message;
//		switch (flag) {
//		case 111:
			originalRecord1.info(in.getHexDump());
//			break;
//		case 166:
//			originalRecord2.info(in.getHexDump());
//			break;
//		case 218:
//			originalRecord3.info(in.getHexDump());
//			break;
//		}
		super.messageReceived(nextFilter, iosession, message);
		
	}
}
